package nl.ajonker.railroad.dl;

import nl.ajonker.railroad.sl.SwitchAddress;

public class SwitchRail {
    public enum SwitchState {
        STRAIGHT, DIVERGING
    }

    private final String name;
    private final SwitchAddress switchAddress;
    private SwitchState switchState = SwitchState.STRAIGHT;

    public SwitchRail(String name, SwitchAddress switchAddress, SwitchState switchState) {
        this(name, switchAddress);
        this.switchState = switchState;
    }

    public SwitchRail(String name, SwitchAddress switchAddress) {
        this.name = name;
        this.switchAddress = switchAddress;
    }

    public SwitchState getSwitchState() {
        return switchState;
    }

    public String getName() {
        return name;
    }

    public SwitchAddress getSwitchAddress() {
        return switchAddress;
    }

    /*package*/ void switchPosition() {
        if (switchState == SwitchState.DIVERGING)
            switchState = SwitchState.STRAIGHT;
        else
            switchState = SwitchState.DIVERGING;
    }
}
